package com.netrust.quarz.utils.db;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DbHelper {
	private boolean dev=true;

	private static String[] dev_proporties=new String[]{"jdbc:mysql://192.168.0.194:3308/spp_dev?characterEncoding=utf8&useSSL=true","user", "user"};
	private static String[] prod_proporties=new String[]{"jdbc:mysql://localhost:3306/spp?characterEncoding=utf8&useSSL=true", "root","root!2#"};

	/**
	 * @param dev 是否是开发阶段 true代表开发测试,false代表正式项目
	 * @return
	 */
	public Connection getConnection() {
		String[] keys=null;
		if(this.dev){
			keys=dev_proporties;
		}else{		
			keys=prod_proporties;
		}
		
		Connection conn = null;
		try {
			Class.forName("com.mysql.jdbc.Driver");
			conn = DriverManager.getConnection(keys[0],keys[1],keys[2]);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return conn;
	}
}
